x86/vlapic: keep timer running when switching between one-shot and periodic mode
authorAnthony PERARD <anthony.perard@citrix.com>
Fri, 25 Aug 2017 14:41:37 +0000 (16:41 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 25 Aug 2017 14:41:37 +0000 (16:41 +0200)
commitd8ce0309c190222b2a44cb217e7f7f3508f3f559
treebe63a93c2c95d7c8f89e8a880ba85c095f2409e2
parente4e1896b2c2ae242660d1401fb352f45953fd4c6
x86/vlapic: keep timer running when switching between one-shot and periodic mode

If we take TSC-deadline mode timer out of the picture, the Intel SDM
does not say that the timer is disable when the timer mode is change,
either from one-shot to periodic or vice versa.

After this patch, the timer is no longer disarmed on change of mode, so
the counter (TMCCT) keeps counting down.

So what does a write to LVTT changes ? On baremetal, the change of mode
is probably taken into account only when the counter reach 0. When this
happen, LVTT is use to figure out if the counter should restard counting
down from TMICT (so periodic mode) or stop counting (if one-shot mode).

This also mean that if the counter reach 0 and the mode is one-shot, a
change to periodic would not restart the timer. This is achieve by
setting vlapic->timer_last_update=0.

This patch is based on observation of the behavior of the APIC timer on
baremetal as well as check that they does not go against the description
written in the Intel SDM.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/vlapic.c